From 81ec3e431241fc6d50046d27bdf029057621095b Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Fri, 18 Mar 2005 09:18:26 +0000 Subject: [PATCH] bitkeeper revision 1.1159.258.60 (423a9ce2eJtKIkEGHQPPRXvkPvoHqQ) Check kmalloc return value in vbd code. Signed-off-by: Keir Fraser --- .../drivers/xen/blkfront/vbd.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/linux-2.6.11-xen-sparse/drivers/xen/blkfront/vbd.c b/linux-2.6.11-xen-sparse/drivers/xen/blkfront/vbd.c index 95f2bd4b3b..f9265e74ec 100644 --- a/linux-2.6.11-xen-sparse/drivers/xen/blkfront/vbd.c +++ b/linux-2.6.11-xen-sparse/drivers/xen/blkfront/vbd.c @@ -496,21 +496,16 @@ int xlvbd_init(void) { int i; - /* - * If compiled as a module, we don't support unloading yet. We - * therefore permanently increment the reference count to - * disallow it. - */ - /* MOD_INC_USE_COUNT; */ - memset(major_info, 0, sizeof(major_info)); - for (i = 0; i < sizeof(major_info) / sizeof(major_info[0]); i++) { + vbd_info = kmalloc(MAX_VBDS * sizeof(vdisk_t), GFP_KERNEL); + if (vbd_info == NULL) { + printk(KERN_ALERT "Failed to allocate memory for disk info.\n"); + nr_vbds = 0; + return 0; } - vbd_info = kmalloc(MAX_VBDS * sizeof(vdisk_t), GFP_KERNEL); nr_vbds = xlvbd_get_vbd_info(vbd_info); - if (nr_vbds < 0) { kfree(vbd_info); vbd_info = NULL; -- 2.30.2